package com.gxa.modules.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.modules.sys.entity.HouseLabel;
import com.gxa.modules.sys.entity.HouseLabelAdd;
import com.gxa.modules.sys.entity.HouseLabelUpdate;
import com.gxa.modules.sys.mapper.HouseLabelMapper;
import com.gxa.modules.sys.service.HouseLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
@Component
public class HouseLabelServiceImpl implements HouseLabelService {
    @Autowired
    private HouseLabelMapper houseLabelMapper;
    @Override
    public PageInfo<HouseLabel> queryHouseLabel(Map<String, Object> params) {

        String page1=(String) params.get("page");
        String limit1=(String)params.get("limit");
        Integer page=Integer.valueOf(page1);
        Integer limit=Integer.valueOf(limit1);

        //条件查询
        String labelName = (String) params.get("labelName");

        PageHelper.startPage(page,limit);

        List<HouseLabel> houseLabels = this.houseLabelMapper.queryHouseLabel(labelName);

        PageInfo<HouseLabel> pageInfo = new PageInfo<>(houseLabels);
        return pageInfo;

    }

    @Override
    public void addHouseLabel(HouseLabelAdd houseLabelAdd) {
        this.houseLabelMapper.addHouseLabel(houseLabelAdd);
    }

    @Override
    public void updateHouseLabel(HouseLabelUpdate houseLabelUpdate) {
        this.houseLabelMapper.updateHouseLabel(houseLabelUpdate);
    }

    @Override
    public void deleteHouseLabel(Integer id) {
        this.houseLabelMapper.deleteHouseLabel(id);
    }
}
